package com.lds.erp.order.impl;

import com.alibaba.dubbo.config.annotation.Reference;
import com.dph.common.utils.service.BaseOrder;
import com.lds.erp.order.OrderOrderClient;
import com.lds.erp.order.order.OrderCreateFacade;
import com.lds.erp.order.order.OrderQueryFacade;
import com.lds.erp.order.order.OrderReturnFacade;
import com.lds.erp.order.order.OrderStatusFacade;
import com.lds.erp.order.order.order.*;
import com.lds.erp.order.order.result.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

/**
 * Created by liuli on 2019/1/8.
 */
@Service
public class OrderOrderClientImpl implements OrderOrderClient {
    private final static Logger logger = LoggerFactory.getLogger(OrderOrderClientImpl.class);
    @Reference(version = "1.0")
    private OrderCreateFacade orderCreateFacade;
    @Reference(version = "1.0")
    private OrderQueryFacade orderQueryFacade;
      @Reference(version = "1.0")
    private OrderStatusFacade orderStatusFacade;

    @Reference(version = "1.0")
    private OrderReturnFacade orderReturnFacade;





    @Override
    public MchCreateOrderResult mchCreateOrder(MchCreateOrderOrder order) {
        logger.info("创建订单,入参={}", order);
        MchCreateOrderResult result = orderCreateFacade.mchCreateOrder(order);
        logger.info("创建订单,出参={}", result);
        return result;
    }

    @Override
    public MchCreatePresaleOrderResult mchCreatePresaleOrder(MchCreatePresaleOrderOrder order) {
        logger.info("创建预售订单,入参={}", order);
        MchCreatePresaleOrderResult result = orderCreateFacade.presaleCreateOrder(order);
        logger.info("创建预售订单,出参={}", result);
        return result;
    }

    @Override
    public MchOrderPayResult mchOrderPay(MchCreateOrderPayOrder order) {
        logger.info("生成订单以后再次支付,入参={}", order);
        MchOrderPayResult result = orderCreateFacade.mchOrderPay(order);
        logger.info("生成订单以后再次支付,出参={}", result);
        return result;
    }

    @Override
    public AppletOrderDetailResult appletOrderDetail(AppletOrderDetailOrder order) {
        logger.info("订单详情,入参={}", order);
        AppletOrderDetailResult result = orderQueryFacade.appletOrderDetail(order);
        logger.info("订单详情,出参={}", result);
        return result;
    }

    @Override
    public AppletOrderQueryResult appletOrderQuery(AppletOrderQueryOrder order) {
        logger.info("订单列表,入参={}", order);
        AppletOrderQueryResult result = orderQueryFacade.appletOrderQuery(order);
        logger.info("订单列表,出参={}", result);
        return result;
    }

    @Override
    public OrderCancelResult orderCancelByOrdOrderNo(OrderCancelOrder order) {
        logger.info("订单取消,入参={}", order);
        OrderCancelResult result = orderStatusFacade.orderCancelByOrdOrderNo(order);
        logger.info("订单取消,出参={}", result);
        return result;
    }

    @Override
    public OrderConfirmReceiveResult orderConfirmReceive(OrderConfirmReceiveOrder order) {
        logger.info("订单商户确认收货,入参={}", order);
        OrderConfirmReceiveResult result = orderStatusFacade.orderConfirmReceive(order);
        logger.info("订单商户确认收货,出参={}", result);
        return result;
    }

    @Override
    public OrderSendTimeResult orderSendTime(OrderSendTimeOrder order) {
        logger.info("订单配送时段查询,入参={}", order);
        OrderSendTimeResult result = orderQueryFacade.orderSendTime(order);
        logger.info("订单配送时段查询,出参={}", result);
        return result;
    }

    @Override
    public OrderApplyReturnResult orderApplyReturn(OrderApplyReturnOrder order) {
        logger.info("订单退货申请,入参={}", order);
        OrderApplyReturnResult result = orderStatusFacade.orderApplyReturn(order);
        logger.info("订单退货申请,出参={}", result);
        return result;
    }

    @Override
    public OrderArriveResult orderArriveByOrdOrderNo(OrderArriveOrder order) {
        logger.info("商户端退货,入参={}", order);
        OrderArriveResult result = orderStatusFacade.orderArriveByOrdOrderNo(order);
        logger.info("商户端退货,出参={}", result);
        return result;
    }

    @Override
    public ReturnComputeResult returnComputeByOrdOrderNo(ReturnComputeOrder order) {
        logger.info("退货订单预计算,入参={}", order);
        ReturnComputeResult result = orderStatusFacade.returnComputeByOrdOrderNo(order);
        logger.info("退货订单预计算,出参={}", result);
        return result;
    }

    @Override
    public QueryOrderReturnResult queryOrderReturn(QueryOrderReturnOrder order) {
        logger.info("退货列表,入参={}", order);
        QueryOrderReturnResult result = orderReturnFacade.queryOrderReturn(order);
        logger.info("退货列表,出参={}", result);
        return result;
    }

    @Override
    public QueryOrderReturnDetailResult queryOrderReturnDetail(QueryOrderReturnDetailOrder order) {
        logger.info("退货详情,入参={}", order);
        QueryOrderReturnDetailResult result = orderReturnFacade.queryOrderReturnDetail(order);
        logger.info("退货详情,出参={}", result);
        return result;
    }

    @Override
    public PresaleOrderDetailResult queryPresaleDetail(PresaleOrderDetailOrder order) {
        logger.info("预售订单详情,入参={}", order);
        PresaleOrderDetailResult result = orderQueryFacade.presaleOrderDetail(order);
        logger.info("预售订单详情,出参={}", result);
        return result;
    }

    @Override
    public OrderJhPayResult jhInfo(BaseOrder order) {
        logger.info("聚合支付预售订单,入参={}", order);
        OrderJhPayResult result = orderQueryFacade.getJhPay(order);
        logger.info("聚合支付预售订单,出参={}", result);
        return result;
    }


}
